package com.chinaztt.fda.Interface;

import android.text.TextUtils;

import com.chinaztt.fda.http.Communication;
import com.chinaztt.fda.http.HttpRequestSuccessListener;
import com.chinaztt.fda.http.HttpState;
import com.chinaztt.fda.parameter.ParFlag;
import com.chinaztt.fda.parameter.ParameterSetting;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;


/**
 * 接口调试  请求接口样式
 * @author zhoulp
 *
 */
public final class Interface {

	private Interface() {}

	/**
	 * 库存订单列表
	 * @param pageNum 第几页
	 * @param eachNumOfPage 每一页显示的条数
	 * @param listener 监听器 
	 */
	public static void orderListStock(int pageNum, int eachNumOfPage, HttpRequestSuccessListener listener) {
		String url = Urls.getIntance().getOrderListStockUrl();
		ArrayList<NameValuePair> paramList = new ArrayList<NameValuePair>();
		String merNo = ParameterSetting.getInstance().getParameter(ParFlag.MERCHANT_ID, "");
		if(TextUtils.isEmpty(merNo)) {
			Communication.notifyError(listener, HttpState.ERR_CODE_HTTP_REQUEST, "商户号为空！");
			return;
		}
		paramList.add(new BasicNameValuePair("data.merNo", merNo));
		paramList.add(new BasicNameValuePair("pageNum", Integer.toString(pageNum)));
		paramList.add(new BasicNameValuePair("numPerPage", Integer.toString(eachNumOfPage)));//每页显示多少条
		Communication.getInstance().post("", url, paramList, listener);
	}


	/**
	 * 删除供应商
	 */

	public static void deleteSupply(String id, HttpRequestSuccessListener listener) {
		String merNo = ParameterSetting.getInstance().getParameter(ParFlag.MERCHANT_ID, "");
		if(TextUtils.isEmpty(merNo)) {
			Communication.notifyError(listener, HttpState.ERR_CODE_HTTP_REQUEST, "商户号为空！");
			return;
		}

		String url = Urls.getIntance().getDeleteSupplyUrl();
		ArrayList<NameValuePair> paramList = new ArrayList<NameValuePair>();
		paramList.add(new BasicNameValuePair("data.merNo",merNo));
		//paramList.add(new BasicNameValuePair("data.terNo", ParameterSetting.getInstance().getParameter(ParFlag.MERCHANT_ID, "")));
		paramList.add(new BasicNameValuePair("data.id", id));
		Communication.getInstance().post("", url, paramList, listener);
	}

}
